const http = require("http");

const sever = http.createServer((req, res) => {
  let str = "hello world";
  if (req.url === "/" || req.url === "/index") {
    str = "<h1>index</h1>";
  } else if (req.url === "/about") {
    str = "<h1>about</h1>";
  } else {
    str = "<h1>404 Not Found</h1>";
  }
  res.setHeader("Content-Type", "text/html;charset=utf-8");
  res.end(str);
});

sever.listen(8080, () => {
  console.log("server is running at http://127.0.0.1:8080");
});
